package com.jms.web.controller.jms.service.impl;

import com.jms.common.filter.utils.DateUtils;
import com.jms.common.filter.utils.SecurityUtils;
import com.jms.web.controller.jms.domain.Worksheet;
import com.jms.web.controller.jms.mapper.WorksheetMapper;
import com.jms.web.controller.jms.service.IWorksheetService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 工单配置Service业务层处理
 * 
 * @author drx
 * @date 2024-09-25
 */
@Service
public class WorksheetServiceImpl implements IWorksheetService
{
    @Resource
    private WorksheetMapper worksheetMapper;

    /**
     * 查询工单配置
     * 
     * @param id 工单配置主键
     * @return 工单配置
     */
    @Override
    public Worksheet selectWorksheetById(Long id)
    {
        return worksheetMapper.selectWorksheetById(id);
    }

    /**
     * 查询工单配置列表
     * 
     * @param worksheet 工单配置
     * @return 工单配置
     */
    @Override
    public List<Worksheet> selectWorksheetList(Worksheet worksheet)
    {
        return worksheetMapper.selectWorksheetList(worksheet);
    }

    /**
     * 新增工单配置
     * 
     * @param worksheet 工单配置
     * @return 结果
     */
    @Override
    public int insertWorksheet(Worksheet worksheet)
    {
        worksheet.setCreateTime(DateUtils.getNowDate());

        worksheet.setCreateTime(DateUtils.getNowDate());
        worksheet.setCreateName(SecurityUtils.getLoginUser().getUser().getNickName());
        worksheet.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
        return worksheetMapper.insertWorksheet(worksheet);
    }

    /**
     * 修改工单配置
     * 
     * @param worksheet 工单配置
     * @return 结果
     */
    @Override
    public int updateWorksheet(Worksheet worksheet)
    {
        worksheet.setUpdateTime(DateUtils.getNowDate());

        worksheet.setUpdateTime(DateUtils.getNowDate());
        worksheet.setUpdateName(SecurityUtils.getLoginUser().getUser().getNickName());
        worksheet.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
        return worksheetMapper.updateWorksheet(worksheet);
    }

    /**
     * 批量删除工单配置
     * 
     * @param ids 需要删除的工单配置主键
     * @return 结果
     */
    @Override
    public int deleteWorksheetByIds(Long[] ids)
    {
        return worksheetMapper.deleteWorksheetByIds(ids);
    }

    /**
     * 删除工单配置信息
     * 
     * @param id 工单配置主键
     * @return 结果
     */
    @Override
    public int deleteWorksheetById(Long id)
    {
        return worksheetMapper.deleteWorksheetById(id);
    }
}
